def CircleCal(r):
    area = 3.14*r*r
    return area
CircleCal(3)
def StudentInfo1(name,*args):
    print("姓名：",name,"其他：",args)
def StudentInfo2(name,**args):
    print("姓名：",name,"其他：",args)
StudentInfo1("陆九愚","良好","日本")
StudentInfo2("陆九愚",中文水平="良好",国籍="日本")
def Lujiuyu(*args):
    sum = 0
    for i in args:
        sum += i
    print("求和结果为：",sum)
Is = [1,2,3,4]
Lujiuyu(Is[0],Is[1],Is[2],Is[3])
def Lujiuyu(*args):
    sum = 0
    for i in args:
        sum += i
    print("求和结果为：",sum)
Is = [1,2,3,4]
Lujiuyu(*Is)
def StudentInfo(name,level,country):
    print("姓名：%s，水平：%s，国籍：%s"%(name,level,country))
d = {"country":"中国","level":"良好","name":"陆九愚"}
StudentInfo(**d)
def Func(*args):
    print(args)
str = "Lujiuyu"
Func(*str)
ls = [1,2,3,4]
Func(*ls)
def PrintFib(n):
    a,b = 1,1
    for i in range(1,n+1):
        print(a,end=' ')
        a,b = b,a+b
print()
def GetFib(n):
    fib = []
    a,b = 1,1
    for i in range(1,n+1):
        fib.append(a)
        a,b = b,a+b
    return fib
PrintFib(10)
ls = GetFib(10)
print(ls)
def Sum(a,b):
    print("Sum函数被调用")
    return a+b

def NewSum(*args):
    print("NewSum函数被调用")
    s=0
    for i in args:
        s +=i
    return s
Sum = NewSum
print(Sum(1,2,3,4))
def outer():
    x = 10
    def inner():
        x = 20
        print("inner中x为",x)
    inner()
    print("outer中x为",x)
outer()
def outer():
    x = 10
    def inner():
        nonlocal x
        x = 20
        print("inner中x为",x)
    inner()
    print("outer中x为",x)
outer()
def fac(n):
    f = 1
    for i in range(2,n+1):
        f*=i
    return f
print(fac(5))
def fac2(n):
    return fac2(n-1)*n
print(fac(5))
def FunAdd(f,x,y):
    return f(x)+f(y)
def Square(x):
    return x**2
def Cube(x):
    return x**3
print(FunAdd(Square,3,5))
print(FunAdd(Cube,3,5))
print(__name__)
def outer(x):
    y = 10
    def inner(z):
        nonlocal x,y
        return x+y+z
    return inner(7)
f = outer(5)
g = outer(50)
def deco1(func):
    def inner1(*args,**kwargs):
        print("deco1 begin")
        func(*args,**kwargs)
        print("deco1 end")
    return inner1
def deco2(func):
    def inner2(*args,**kwargs):
        print("deco2 begin")
        func(*args,**kwargs)
        print("deco2 end")
    return inner2

@deco1
def f1(a,b):
    print("a+b=",a+b)
@deco1

@deco2
def f2(a,b,c):
    print("a+b+c=",a+b+c)
if __name__ == '__main__':
    f1(3,5)
    f2(1,2,3)
